home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 May / maximum-cd-1999-05.iso / Canvas 6 / DATA1.CAB / English_Tutorial_Files / Viewpage / ColGrph.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-04  |  3.0 KB  |  175 lines

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Font;
  4. import java.awt.FontMetrics;
  5. import java.awt.Frame;
  6. import java.awt.Graphics;
  7. import java.awt.MediaTracker;
  8. import java.awt.Rectangle;
  9.  
  10. public class ColGrph {
  11.    public float m_magChck;
  12.    public int m_sx;
  13.    public int m_sy;
  14.    private int m_firstX;
  15.    private int m_firstY;
  16.    private int m_newOrgX;
  17.    private int m_newOrgY;
  18.    private Rectangle m_zmBuf;
  19.    private Rectangle m_panRect;
  20.    private boolean m_didPan;
  21.    private float m_lstMag = 1.0F;
  22.    private float m_lstX;
  23.    private float m_lstY;
  24.    public float m_xOrg;
  25.    public float m_yOrg;
  26.    public float m_mag = 1.0F;
  27.    public ColUrl m_curURL;
  28.    public ColObjIntr m_curObj;
  29.    public Graphics m_graphicsBuffer;
  30.    public Graphics m_mainGraphic;
  31.    public Color m_overrideColor;
  32.    public Color m_bkGrndClr;
  33.    public Font m_font;
  34.    public FontMetrics m_fontMtrc;
  35.    public Rectangle m_bounds;
  36.    public MediaTracker m_tracker;
  37.    public Colada m_appComp;
  38.  
  39.    public void panDrw(int var1, int var2) {
  40.       int var3 = var1 - this.m_firstX;
  41.       int var4 = var2 - this.m_firstY;
  42.       int var5 = (int)(this.m_xOrg - (float)var3 / this.m_mag);
  43.       int var6 = (int)(this.m_yOrg - (float)var4 / this.m_mag);
  44.       this.m_newOrgX = var5;
  45.       this.m_newOrgY = var6;
  46.       this.m_didPan = true;
  47.    }
  48.  
  49.    public void panOff() {
  50.       if (this.m_didPan) {
  51.          this.m_xOrg = (float)this.m_newOrgX;
  52.          this.m_yOrg = (float)this.m_newOrgY;
  53.       }
  54.  
  55.       ((Frame)this.m_appComp.m_comp).setCursor(3);
  56.    }
  57.  
  58.    public void colZoom(float var1) {
  59.       this.m_magChck = this.m_mag + var1;
  60.       if (this.m_magChck >= 0.1F && this.m_magChck <= 5.0F) {
  61.          if (var1 == 0.0F) {
  62.             this.m_mag = 1.0F;
  63.             this.m_magChck = 1.0F;
  64.             this.m_xOrg = 0.0F;
  65.             this.m_yOrg = 0.0F;
  66.             return;
  67.          }
  68.  
  69.          this.m_xOrg += (float)this.m_sx / this.m_mag - (float)this.m_sx / this.m_magChck;
  70.          this.m_yOrg += (float)this.m_sy / this.m_mag - (float)this.m_sy / this.m_magChck;
  71.          this.m_mag += var1;
  72.       }
  73.  
  74.    }
  75.  
  76.    void drawAll(Graphics var1) {
  77.       ColUrl var2 = this.m_curURL;
  78.       ColObjIntr var3 = this.m_curObj;
  79.       Rectangle var4 = var1.getClipRect();
  80.       var4.x = (int)((float)var4.x / this.m_mag + this.m_xOrg);
  81.       var4.y = (int)((float)var4.y / this.m_mag + this.m_yOrg);
  82.       var4.width = (int)((float)var4.width / this.m_mag + this.m_xOrg);
  83.       var4.height = (int)((float)var4.height / this.m_mag + this.m_xOrg);
  84.       int var5 = 0;
  85.       boolean var6 = true;
  86.       int var7 = 0;
  87.       char[] var8 = this.m_appComp.layerFlags.toCharArray();
  88.       if (this.m_mag > 1.0F) {
  89.          label63:
  90.          while(true) {
  91.             if (var2 == null || this.m_appComp.m_breakDrawAll) {
  92.                while(true) {
  93.                   if (var3 == null || this.m_appComp.m_breakDrawAll) {
  94.                      break label63;
  95.                   }
  96.  
  97.                   if (var3.getType() == 15) {
  98.                      if (var8[var7] == 'V') {
  99.                         var6 = true;
  100.                      } else {
  101.                         var6 = false;
  102.                      }
  103.  
  104.                      ++var7;
  105.                   }
  106.  
  107.                   if (var6) {
  108.                      var3.draw(var1);
  109.                      ++var5;
  110.                      Thread.currentThread();
  111.                      Thread.yield();
  112.                   }
  113.  
  114.                   var3 = var3.getNext();
  115.                }
  116.             }
  117.  
  118.             var2.draw(var1);
  119.             var2 = (ColUrl)((ColObj)var2).getNext();
  120.          }
  121.       } else {
  122.          while(var2 != null && !this.m_appComp.m_breakDrawAll) {
  123.             var2.draw(var1);
  124.             var2 = (ColUrl)((ColObj)var2).getNext();
  125.          }
  126.  
  127.          for(; var3 != null && !this.m_appComp.m_breakDrawAll; var3 = var3.getNext()) {
  128.             if (var3.getType() == 15) {
  129.                if (var8[var7] == 'V') {
  130.                   var6 = true;
  131.                } else {
  132.                   var6 = false;
  133.                }
  134.  
  135.                ++var7;
  136.             }
  137.  
  138.             if (var6) {
  139.                var3.draw(var1);
  140.                ++var5;
  141.             }
  142.          }
  143.       }
  144.  
  145.       ((Frame)this.m_appComp.m_comp).setCursor(0);
  146.       this.m_appComp.m_breakDrawAll = false;
  147.       System.gc();
  148.    }
  149.  
  150.    ColGrph(Colada var1) {
  151.       this.m_bkGrndClr = Color.white;
  152.       this.m_appComp = var1;
  153.       this.m_bounds = ((Component)var1).bounds();
  154.       this.m_mainGraphic = ((Component)var1).getGraphics();
  155.       this.m_graphicsBuffer = ((Component)var1).getGraphics();
  156.       this.m_sx = this.m_bounds.width / 2;
  157.       this.m_sy = this.m_bounds.height / 2;
  158.       this.m_tracker = new MediaTracker(var1);
  159.       this.m_mainGraphic.clipRect(0, 0, this.m_bounds.width, this.m_bounds.height);
  160.    }
  161.  
  162.    public void finalize() {
  163.       this.m_graphicsBuffer.dispose();
  164.       this.m_mainGraphic.dispose();
  165.    }
  166.  
  167.    public void panOn(int var1, int var2) {
  168.       this.m_didPan = false;
  169.       this.m_firstX = var1;
  170.       this.m_firstY = var2;
  171.       this.m_panRect = new Rectangle(this.m_bounds.x, this.m_bounds.y, (int)((float)this.m_bounds.width - (float)this.m_bounds.width / this.m_mag), (int)((float)this.m_bounds.height - (float)this.m_bounds.height / this.m_mag));
  172.       ((Frame)this.m_appComp.m_comp).setCursor(13);
  173.    }
  174. }
  175.